<?
include("session.php");
$id = "";
if(isset($_GET['id'])) {
	$id = $_GET['id'];
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../webkit/utils/jquery.js"></script>
<script type="text/javascript" src="../webkit/utils/form.checker.js"></script>
<script type="text/javascript" src="../webkit/datepicker/WdatePicker.js"></script>
<link type="text/css" rel="stylesheet" href="page.css"/> 
<body  bgcolor="#f4f4f4" style="margin:2px; font-size:12px" scroll=no>

【<a href="javascript:show_panel('order_info')" class="gray">定单信息</a>】　【<a href="javascript:show_panel('handle_info')" class="gray">操作信息</a>】
<hr size=1>
<table width=100% cellspacing=1 cellpadding=3 id="order_info_panel"> 
	<form name=f> 
	<tr>
        <td align=right nowrap>定单编号</td><td><input type='text' id="order_no" class='input' disabled></td>  
		<td align=right>定单来源</td>
		<td>
			<select id="order_status" class='input' disabled><option value='1'>网站</option><option value='2'>400热线</option><option value='3'>手机</option></select>
		</td>
	</tr>
	<tr>
		<td align=right>商品名称</td><td><input type='text' id="product" class='input' readonly value="闸蟹"></td>
		<td align=right nowrap>定购数量</td><td><select id="count" class='input' onchange="calcute_price_total('count', this.value)"><option value=6>6</option><option value=8>8</option><option value=10>10</option><option value=12>12</option><option value=16>16</option></select></td> 
	</tr>
	<tr>
		<td align=right>商品类型</td><td><select id="type" class='input'  onchange="calcute_price_total('type', this.value)"><option value='小'>小</option><option value='中'>中</option><option value='大'>大</option></select></td>
		<td align=right>单　　价</td><td><input type='text' id="price" class='input' value=15 readonly></td>
	</tr>
	<tr>
		<td align=right>包　　装</td><td><select id="box" class='input' onchange="calcute_price_total('box', this.value)"><option value='标准'>标准</option><option value='礼品袋'>礼品袋</option></select></td>
		<td align=right>定单金额</td><td><input type='text' id="total" class='input' value=60 readonly></td>
	</tr>
	<tr>
		<td align=right>顾客名称</td><td><input type='text' id="truename" class='input' check='not_empty' warning='顾客名称不能为空！'></td>
		<td align=right nowrap>联系电话</td><td><input type='text' id="mobile" class='input' check='not_empty' warning='联系电话不能为空！'></td>
	</tr>
	<tr>
		<td align=right>区　　域</td><td><select id="area" class='input'><option value='长沙市'>长沙市</option><option value='芙蓉区'>芙蓉区</option><option value='天心区'>天心区</option><option value='雨花区'>雨花区</option><option value='岳麓区'>岳麓区</option><option value='开福区'>开福区</option><option value='望城区'>望城区</option></select></td>
		<td align=right>定单状态</td><td><select id="order_status" class='input' disabled><option value='1'>等待受理</option><option value='2'>正在备货</option><option value='3'>配送途中</option><option value='4'>完成购物</option><option value='-1'>用户取消</option></select></td>
	</tr>
	<tr>
		<td align=right>收货地址</td><td colspan=3><input type='text' id="address" class='input' check='not_empty' warning='收货地址不能为空！' style="width:500px"></td>
	</tr>
	<tr>
		<td align=right>备　　注</td><td colspan=3><textarea style="width:500px;" rows=3 id="content"></textarea></td>
	</tr>
	<input type='hidden' id="id">
	</form>	
</table>


<table width=100% cellspacing=1 cellpadding=3 id="handle_info_panel" style="display:none"> 
	<tr>
        <td align=right nowrap>收货时间</td><td><input type='text' id="confirm_time" class='input' readonly></td>  
		<td align=right>操作时间</td><td><input type='text' id="handle_time" class='input' readonly></td>
	</tr>
	<tr>
		<td align=right>操作备注</td><td colspan=3><textarea style="width:500px;" rows=3 id="handle_desc" readonly></textarea></td>
	</tr>
	<tr>
        <td align=right nowrap>评价时间</td><td><input type='text' id="comment_time" class='input' readonly></td>  
		<td align=right>评价分值</td><td>
		<select id="comment_score" class='input' disabled>
			<option value=''></option>
			<option value='1'>体验不好</option>
			<option value='2'>需要改进</option>
			<option value='3'>一般</option>
			<option value='4'>满意</option>
			<option value='5'>非常满意</option>
		</select></td>
	</tr>
	<tr>
		<td align=right>操作备注</td><td colspan=3><textarea style="width:500px;" rows=3 id="comment_desc" readonly></textarea></td>
	</tr>
	<tr>
        <td align=right nowrap>取消时间</td><td><input type='text' id="cancel_time" class='input' readonly></td>  
		<td align=right>取消原因</td><td>
		<select class="input" id="cancel_reason" disabled>
		<option value=''></option>
		<option value='1'>定单填写错误</option>
		<option value='2'>暂时不想买了</option>
		<option value='3'>配送延时问题</option>
		<option value='4'>其它服务问题</option>
		</select></td>
	</tr>
	<tr>
		<td align=right>取消备注</td><td colspan=3><textarea style="width:500px;" rows=3 id="cancel_desc" readonly></textarea></td>
	</tr>
</table>


<table width=100% cellspacing=1 cellpadding=3>
	<tr>
		<td align=center>
		<hr size=1>
		<input type="button" id="btn_save" class="button" value="保存信息" onclick="save()">　　<input type="button" class="button" value="关闭窗口" onclick="parent.closeDlg()"></td>
	</tr>
</table>

<script type="text/javascript">
	var op = "<?echo $_GET['op']?>";
	var f = document.f;
	function save() { 
		if(FormChecker.doCheck(f)) {
			var params = {};
			var els = f.elements;
			for(var i=0; i<els.length; i++) {
				if(els[i].type == "button") continue;
				params[els[i].id] = els[i].value;
			}
			
			if(confirm('确定要保存信息吗？')) {
				$("#btn_save").attr("disabled", true);
				$("#btn_save").val("正在处理");
				$.post("order_query.php?action="+op, params, function(data) {
					if(data.indexOf("ok") == 0) {
						alert("数据保存成功!");
						parent.refreshGrid();
						parent.closeDlg();
					} else {  
						alert(data);
					}
					$("#btn_save").attr("disabled", false);
					$("#btn_save").val("保存信息");
				});
			}
		}
	}; 

	var current_panel = "order_info";
	function show_panel(c) {
		if(c != current_panel) {
			$("#"+c+"_panel").show();
			$("#"+current_panel+"_panel").hide();
			current_panel = c;
		}
	}


	function init() {
	<?
	if($_GET['op'] == 'edit') {
	?>
	$.get("order_query.php?action=get&id=<?echo $_GET['id']?>", function(data){
		//alert(data)
		eval("var row = "+data);
		for(var k in row) {
			$('#'+k).val(row[k]);
		}
	});
	<?
	}
	?>
	}

	$(function() {
		init();
	});

	var type = "小";
	var count = "6"; // count = "2对";
	var box = "标准";
	var price = "15";
	var total = "60"

	function calcute_price_total(g, v) {
		eval(g+" = '"+v+"'");
		price = type_price[type];
		total = price * parseInt(count) + box_price[box]; // count_arr[count]
		$("#price").val(price);
		$("#total").val(total);
	}

	var type_price = {"小": 15, "中":20, "大":25};
	var box_price = {"标准":0, "礼品袋":8};
</script>
</body>
</html>